package com.example.javademo;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.NonNull;

public class TestDialog extends Dialog {

    public TestDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_alert);
        // ✅ 设置按钮点击事件
        Button btnOk = findViewById(R.id.btn_dialog);
        Button btnCancel = findViewById(R.id.btn_dialog2);

        btnOk.setOnClickListener(v -> {
            // 点击“确定”按钮
            dismiss(); // 关闭对话框
        });

        btnCancel.setOnClickListener(v -> {
            // 点击“取消”按钮
            dismiss(); // 关闭对话框
        });
    }
}
